<?php 
if(!isset($_SESSION)) 
{ 
	session_start(); 
}
if(isset($_REQUEST['tenfile'])){
	$file="backupsql/".$_REQUEST['tenfile'];
	if(is_file($file)==TRUE){
		$f=fopen($file, "r");
		if($f!=FALSE){
			$connectionrs = mysql_connect("1.234.53.52", "cam", "5678" ) ;
			mysql_select_db("testbk130108", $connectionrs);
			mysql_query("set names 'utf8'");
			$noidung='';
			while(!feof($f)){
				if($noidung==''){
					$noidung = chop(fgets($f));
				}else{
					$noidung .= chop(fgets($f));
				}
			}
			$mm=split(" ; ", $noidung);
			$soluong=count($mm);
			echo $soluong;
			if($soluong>0){
				for($i=0;$i<$soluong;$i++){
					echo $mm[$i];"<br>";
					if($mm[$i]!=''){
						mysql_query($mm[$i]);
					}
				}
			}
			
			fclose($f);
			//unlink($file);
			include 'obj_app.php';
			$id_employee='1323404319486';
			$_SESSION['bklist']=array();
			$sql="SELECT a.*,e.FullName	FROM approvedoc a,employee e WHERE a.IDEmployee=e.IDEmployee  and a.IDLabel<1 AND a.IDEmployee='$id_employee' AND a.IDStatus=1 ";
			$query= mysql_query($sql." ORDER BY a.Timecreate desc",$connectionrs);
			$sl=mysql_num_rows($query);
			if($sl>0){
				while($row=mysql_fetch_array($query)){
					$obj= new appobj();
					$obj->newapprovedoc($row['FullName'], $row['IDApproveDoc'], $row['Tile'], $row['Content'], $row['IDEmployee'], $row['IDGroupApprove'], $row['SumMoney'], $row['Timecreate'], $row['IDStatus'], $row['IDTypeDoc'], $row['TimeApprove'], $row['comment'], $row['Description'], $row['purpose'], $row['Location'], $row['TripDate'], $row['TotalTime'], $row['EmployeePerforment'], $row['Content2'], $row['isView'], $row['IDLabel']);
					$_SESSION['bklist'][$row['IDApproveDoc']]=$obj;
				}
			}
			
			$sl=count($_SESSION['bklist']);
			mysql_close($connectionrs);
			?>
			<table border="1" style="width:100%">
	    		<tr>
	    			<td width="3%"><input type="checkbox" name="chonhetroi" id="chonhetroi" onclick="clickChonHetRoi(this);"/></td>
					<td width="3%">No.</td>
		            <td width="15%">Type</td>
		            <td width="30%">Title</a></td>
		            <td width="10%">Time created</a></td>
		            <td width="10%">Time approved</a></td>
	    		</tr>
	    	<?php 
	    		if($sl>0){
	    			$ob= new appobj();
	    			$i=0;
	    			foreach ($_SESSION['bklist'] as $k=>$gt){
	    				$ob=unserialize (serialize ($gt));
	    				?>
	    				<tr bgcolor="#ffffff" class="highlighter">
							<td><input type="checkbox" id="chon" name="xoa[]" value="<?=$ob->idapprovedoc?>" /></td>
							<td width="3%" align="center"><?=(++$i)?></td>
							<td ><div  align="left" ><?=$ob->idtypedoc?></div></td>
							<td >
								<?=$ob->title?>							
							</td>
							<td ><?=$ob->timecreat?></td>
							<td ><?=$ob->timeapprove?></td>
							
						</tr>
	    				<?php 
	    			}
	    		}
	    	?>
	    	</table>
			<?php 			
		}
	}
}
?>